package monster.com.cvh.fragment;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import butterknife.BindView;
import butterknife.OnClick;
import monster.com.cvh.R;
import monster.com.cvh.activity.MyCommentActivity;
import monster.com.cvh.activity.PraiseActivity;
import monster.com.cvh.fragment.base.PermissionFragment;
import monster.com.cvh.util.SPUtils;

/**
 * @author: monster
 * @data: 2018/3/29
 * @function: 消息界面
 */
public class MessageFragment extends PermissionFragment {
    @BindView(R.id.iv_fragment_message_point)
    ImageView mIvFragmentMessagePoint;
    @BindView(R.id.ll_fragment_message_commont)
    LinearLayout mLlFragmentMessageCommont;
    @BindView(R.id.iv_fragment_message_praise_point)
    ImageView mIvFragmentMessagePraisePoint;
    @BindView(R.id.ll_fragment_message_praise)
    LinearLayout mLlFragmentMessagePraise;
    private static final String TAG = "lixiaofei";

    @Override
    protected int getLayoutResId() {
        return R.layout.fragment_message;
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onResume() {
        super.onResume();
        //默认为false
        boolean showComment = SPUtils.getBoolean(getActivity(), "showComment", false);
        boolean showPraise = SPUtils.getBoolean(getActivity(), "showPraise", false);
        if (showComment){
            //为true 显示
            mIvFragmentMessagePoint.setImageResource(R.mipmap.xh_point);
        }else {
            //为false 不显
            mIvFragmentMessagePoint.setVisibility(View.INVISIBLE);
        }
        if (showPraise){
            //为true 显示
            mIvFragmentMessagePraisePoint.setImageResource(R.mipmap.xh_point);
        }else {
            //为false
            mIvFragmentMessagePraisePoint.setVisibility(View.INVISIBLE);
        }
    }

    @Override
    protected void initEvent() {

    }


    /**
     * 评论界面
     */
    @OnClick(R.id.ll_fragment_message_commont)
    public void onMLlFragmentMessageCommontClicked() {
        SPUtils.putBoolean(getActivity(),"showComment",false);
        startActivity(new Intent(getActivity(), MyCommentActivity.class));
    }

    /**
     * 点赞界面
     */
    @OnClick(R.id.ll_fragment_message_praise)
    public void onMLlFragmentMessagePraiseClicked() {
        startActivity(new Intent(getActivity(), PraiseActivity.class));
        SPUtils.putBoolean(getActivity(),"showPraise",false);
    }
}
